/**
 * Copyright (C)  Gadglet .
 *
 * This file is part of Gadglet
 *
 * Gadglet is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Gadglet is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with Gadglet. If not, see <http://www.gnu.org/licenses/>.
 */

package com.gadglet.data;
import java.util.Date;

import javax.jdo.annotations.Extension;
import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

/**
 * Persistence class for Minglets users friends
 *
 */
@PersistenceCapable
public class Friends {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	@Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")
	private String id;
	
	
	@Persistent
	private String initBy;
		
	@Persistent
	private String confirmedBy;
	
	@Persistent
	private Date creation;

	Friends(String initBy, String confirmedBy) {

		this.initBy = initBy;
		this.confirmedBy = confirmedBy;
		this.creation = new java.util.Date();
	}

	public String getInitBy() {
		return initBy;
	}

	public void setInitBy(String initBy) {
		this.initBy = initBy;
	}

	public String getConfirmedBy() {
		return confirmedBy;
	}

	public void setConfirmedBy(String confirmedBy) {
		this.confirmedBy = confirmedBy;
	}

	public String getId() {
		return id;
	}

	public Date getCreation() {
		return creation;
	}
	
	public String getFriendId(String myId){
		if(myId.equals(this.confirmedBy))
			return this.initBy;
		else
			return this.confirmedBy;
	}
	
	
	
}
